From e4ec96184f02068ea6378ea8492c85a7a803d32b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 8 Jul 2021 16:22:45 +0200 Subject: [PATCH] debian: Run tests under wayland too in linux It's now becoming the default backend so better to also test the library there. --- debian/control | 1 + debian/control.in | 1 + debian/log-reftests.py | 6 ++-- debian/rules | 17 ++++++--- debian/run-tests.sh | 2 +- debian/tests/run-with-display | 67 +++++++++++++++++++++++++++++++++++ 6 files changed, 86 insertions(+), 8 deletions(-) create mode 100755 debian/tests/run-with-display diff --git a/debian/control b/debian/control index 0db4754df7..3108cd5858 100644 --- a/debian/control +++ b/debian/control @@ -55,6 +55,7 @@ Build-Depends: adwaita-icon-theme , sassc, ttf-bitstream-vera , wayland-protocols (>= 1.21) [linux-any], + weston [linux-any] , xauth , xsltproc, xvfb , diff --git a/debian/control.in b/debian/control.in index c7c1ee317e..eed246eb17 100644 --- a/debian/control.in +++ b/debian/control.in @@ -55,6 +55,7 @@ Build-Depends: adwaita-icon-theme , sassc, ttf-bitstream-vera , wayland-protocols (>= 1.21) [linux-any], + weston [linux-any] , xauth , xsltproc, xvfb , diff --git a/debian/log-reftests.py b/debian/log-reftests.py index b06c8d892f..50ff417cd8 100755 --- a/debian/log-reftests.py +++ b/debian/log-reftests.py @@ -11,11 +11,11 @@ if __name__ == '__main__': for outputs in ( Path( 'debian', 'build', 'deb', 'testsuite', 'gsk', 'compare', - 'opengl', 'x11', + 'opengl', 'x11', 'wayland' ), Path( 'debian', 'build', 'deb', 'testsuite', 'gsk', 'compare', - 'broadway', 'x11', + 'broadway', 'x11', 'wayland' ), ): diff = (outputs / (node.stem + '.diff.png')) @@ -39,7 +39,7 @@ if __name__ == '__main__': for outputs in ( Path( 'debian', 'build', 'deb', 'testsuite', 'reftests', - 'output', 'x11', + 'output', 'x11', 'wayland' ), ): diff = (outputs / (ui.stem + '.diff.png')) diff --git a/debian/rules b/debian/rules index 6913ea62d0..1d288616be 100755 --- a/debian/rules +++ b/debian/rules @@ -173,8 +173,13 @@ ifneq ($(filter %-udeb,$(built_binaries)),) dh_auto_build --builddirectory=debian/build/udeb endif +test_backends = x11 test_timeout_multiplier = 1 +ifeq (linux,$(DEB_HOST_ARCH_OS)) + test_backends += wayland +endif + ifneq ($(filter arm hppa mips% sparc%,$(DEB_HOST_ARCH_CPU)),) $(info Slow architecture detected, increasing test timeout) test_timeout_multiplier = 10 @@ -204,11 +209,15 @@ xfail_reftests = \ # gtk:gsk+gsk-compare+gsk-broadway+gsk-compare-broadway / broadway blend-normal # gtk:gsk+gsk-compare+gsk-broadway+gsk-compare-broadway / broadway blend-difference # s390x: many (endianness?) + override_dh_auto_test: - env BUILDDIR=debian/build/deb \ - FUZZY_REFTESTS="$(fuzzy_reftests)" \ - XFAIL_REFTESTS="$(xfail_reftests)" \ - debian/run-tests.sh -t $(test_timeout_multiplier) + set -e; for backend in $(test_backends); do \ + env BUILDDIR=debian/build/deb \ + FUZZY_REFTESTS="$(fuzzy_reftests)" \ + XFAIL_REFTESTS="$(xfail_reftests)" \ + BACKEND=$$backend \ + debian/run-tests.sh -t $(test_timeout_multiplier); \ + done override_dh_auto_install: dh_auto_install --builddirectory=debian/build/deb --destdir=debian/install/deb diff --git a/debian/run-tests.sh b/debian/run-tests.sh index aee985d08a..e0ece616c2 100755 --- a/debian/run-tests.sh +++ b/debian/run-tests.sh @@ -48,7 +48,7 @@ env \ GIO_USE_VFS=local \ GIO_USE_VOLUME_MONITOR=unix \ dbus-run-session -- \ - xvfb-run -a -s "-screen 0 1024x768x24 -noreset" \ + debian/tests/run-with-display "$BACKEND" \ debian/tests/run-with-locales \ --generate de_DE.UTF-8 \ --generate en_GB.UTF-8 \ diff --git a/debian/tests/run-with-display b/debian/tests/run-with-display new file mode 100755 index 0000000000..3fa2d46e3b --- /dev/null +++ b/debian/tests/run-with-display @@ -0,0 +1,67 @@ +#!/bin/sh +# vim:set sw=4 sts=4 et: +# +# Run a wrapped command in a fake display environment +# +# Copyright 2021 Marco Trevisan +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Assume a Debian Policy §10.4-compatible shell like dash or bash (with the +# 'local' builtin) +# shellcheck disable=SC2039 + +set -e + +me="$(basename "$0")" + +usage () { + local status="${1-2}" + + if [ "$status" -ne 0 ]; then + exec >&2 + fi + + echo "Usage: $me [wayland|x11] COMMAND [ARGS...]" + exit "$status" +} + +display="$1" + +case "$display" in + wayland) + shift + if [ -z "$XDG_RUNTIME_DIR" ]; then + our_xrd="$(mktemp -d -t xdg-runtime-XXXXXXXX)" + export XDG_RUNTIME_DIR="$our_xrd" + fi + if ! command -v weston > /dev/null; then + echo "No weston available" + exit 1 + fi + socket="wayland-$(od -vAn -N1 -tu1 < /dev/urandom | tr -d '[:space:]')" + weston --backend=headless-backend.so --socket="$socket" --idle-time=0 2>&1 & + weston_pid=$! + trap 'kill $weston_pid; [ -n $our_xrd ] && rm -rfv $our_xrd' EXIT INT + while [ ! -S "$XDG_RUNTIME_DIR/$socket" ]; do + echo "Waiting for socket..." + sleep 1 + done + env -u DISPLAY WAYLAND_DISPLAY="$socket" "$@" + exit $? + ;; + x11) + shift + if ! command -v xvfb-run > /dev/null; then + echo "No xvfb-run available" + exit 1 + fi + exec env -u WAYLAND_DISPLAY xvfb-run -a -s "-screen 0 1024x768x24 -noreset" "$@" + ;; + -h|--help|help) + usage 0 + ;; + *) + usage 2 + ;; +esac -- 2.30.2